package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.bean.BrowseHistoryBean;
import com.dingwei.superiordiary.bean.LogisticsLogBean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2018/1/8.
 */

public class LogisticsLogAdapter extends RecyclerArrayAdapter<LogisticsLogBean.DataBean.LogBean> {


    public LogisticsLogAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new LogisticsLogHolder(parent);
    }

    class LogisticsLogHolder extends BaseViewHolder<LogisticsLogBean.DataBean.LogBean> {


        @Bind(R.id.line_top)
        TextView lineTop;
        @Bind(R.id.line_dot)
        ImageView lineDot;
        @Bind(R.id.line_bottom)
        TextView lineBottom;
        @Bind(R.id.tv_content)
        TextView tvContent;
        @Bind(R.id.tv_time)
        TextView tvTime;

        public LogisticsLogHolder(ViewGroup parent) {
            super(parent, R.layout.item_logistics_log);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(LogisticsLogBean.DataBean.LogBean data) {
            super.setData(data);

            tvContent.setText(data.AcceptStation);
            tvTime.setText(data.AcceptTime);
            if (getDataPosition()==0){
                lineTop.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.parting_line));
                lineBottom.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.parting_line));
                lineDot.setImageResource(R.drawable.dot);
                tvContent.setTextColor(BaseActivity.context.getResources().getColor(R.color.theme_color));
                tvTime.setTextColor(BaseActivity.context.getResources().getColor(R.color.theme_color));
                lineTop.setVisibility(View.GONE);
            }else {
                lineTop.setVisibility(View.VISIBLE);
                tvContent.setTextColor(BaseActivity.context.getResources().getColor(R.color.text_color_black));
                tvTime.setTextColor(BaseActivity.context.getResources().getColor(R.color.text_color_gray));
                lineTop.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.parting_line));
                lineBottom.setBackgroundColor(BaseActivity.context.getResources().getColor(R.color.parting_line));
                lineDot.setImageResource(R.drawable.dot_line);
            }

        }
    }
}
